# -*- coding:utf-8 -*-
from flask import Flask, render_template, session, redirect, url_for, escape, request

# from dpl import selected_grade
import json
app = Flask(__name__)



@app.route('/login')
def login():
    return render_template('login.html')

@app.route('/loginAction',methods=['GET', 'POST'])
def login_action():
    user_pass = request.form.get('userpass')
    user_name = request.form.get('username')
    print('username',user_name)
    print('user_pass',user_pass)
    result['infostatus'] = 'F'
    if request.method == 'POST':
        if result['infostatus']=='T':
            session['username'] = user_name
            return json.dumps(result)
        else:
            return json.dumps(result)

@app.route('/antd')
def test_antd():
    # session.pop('username',None)
    name = 0
    if 'username' in session:
        name = session['username']
    return render_template('antd.html',username=name)


@app.route('/userlist')
def get_user():
    userlist = ['a', 'b']
    return json.dumps(userlist)

@app.route('/backLogin')
def back_login():
    session.pop('username',0)
    return redirect('/login')

# for session
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'

if __name__ == '__main__':
    app.run(host='0.0.0.0',port=8001,debug=True)